home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks96
/
FlyPaper.sit
/
Fly Paper
/
FlyPaper Source
/
App Sources
/
Thumbnail.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-22
|
2KB
|
91 lines
#include "ST_MacClasses.h"
#ifndef THUMBNAIL_H
#include "Thumbnail.h"
#endif
#ifndef CLIPPINGFILE_H
#include "ClippingFile.h"
#endif
#ifndef FLYPAPERUTILS_H
#include "FlyPaperUtils.h"
#endif
#define kDictionaryResType 'Info'
#define kDictionaryResID 128
class CGenericThumbnail : public CThumbnail
{
public:
CGenericThumbnail (CClippingFile* file, FlavorType primaryFlavor);
~CGenericThumbnail ();
virtual void Draw (Rect& r);
private:
unsigned char fName [32];
};
CThumbnail::CThumbnail (CClippingFile* file) :
fFile (file)
{
}
CThumbnail::~CThumbnail ()
{
}
CThumbnail* CThumbnail::NewThumbnail (CClippingFile* file, Rect& bounds)
{
FlavorType flavor;
file -> GetIndFlavorType (1, flavor);
return new CGenericThumbnail (file, flavor);
}
CGenericThumbnail::CGenericThumbnail (CClippingFile* file, FlavorType primaryFlavor) :
CThumbnail (file)
{
Handle dictionary;
short count;
dictionary = Get1Resource (kDictionaryResType, kDictionaryResID);
if (!dictionary)
throw resNotFound;
count = **((short**)dictionary);
FlavorType* f = (FlavorType*) (*dictionary + sizeof (short));
unsigned char* s = ((unsigned char*)f) + 4;
Boolean foundIt = false;
for (short i = 0; i < count; ++i) {
short len = *s;
if (*f == primaryFlavor) {
BlockMoveData (s, fName, (len > 31) ? 32 : len + 1);
foundIt = true;
break;
}
f = (FlavorType*) (s + s[0] + 1);
s = ((unsigned char*)f) + 4;
}
if (!foundIt) {
fName [0] = 6;
fName [1] = '\'';
*((FlavorType*) &fName [2]) = primaryFlavor;
fName [6] = '\'';
}
}
void CGenericThumbnail::Draw (Rect& r)
{
TextFont (geneva);
TextSize (9);
MoveTo (r.left, r.bottom - 4);
DrawString (fName);
}
CGenericThumbnail::~CGenericThumbnail ()
{
}